﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Video;

namespace ForestFirePreventionGeography
{
    /// <summary>
    /// 主窗体
    ///     显示地图
    ///     实现各模块间的相互调用
    /// </summary>
    public partial class FormMain : FormMap
    {
        Dictionary<string, List<string>> devices;
        Dictionary<string, Dictionary<string, VideoControl>> videos = new Dictionary<string, Dictionary<string, VideoControl>>();
        Dictionary<string, Dictionary<string, DeviceElement>> mapDevices = new Dictionary<string, Dictionary<string, DeviceElement>>();
        Random random = new Random();

        public FormMain()
        {
            //获取区域设备列表
            devices = VideoBase.GetAreaDeviceList();

            foreach (var area in devices)
            {
                Dictionary<string, VideoControl> areaVideos = new Dictionary<string,VideoControl>();
                Dictionary<string, DeviceElement> areaDeices = new Dictionary<string, DeviceElement>();
                videos.Add(area.Key, areaVideos);
                mapDevices.Add(area.Key, areaDeices);

                foreach (var device in area.Value)
                {
                    //创建视频控件
                    VideoControl video = new VideoControl();
                    video.Initialize(area.Key, device);
                    //创建地图设备
                    DeviceElement mapDevice = new DeviceElement(this, area.Key, device, new Point(Convert.ToInt32(video.Longitude), Convert.ToInt32(video.Latitude)), video.High);

                    mapDevice.VideoHorizon = (short)(random.Next(360));
                    mapDevice.VideoVertical = (short)(random.Next(300, 350));

                }
            }

            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            base.LoadMap();
        }
    }
}
